﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Press.MVC.Data
{
    public static class BlogFilters
    {
        public static IQueryable<Blog> WithBlogId(this IQueryable<Blog> query, int Id)
        {
            return from b in query where b.ID == Id select b;
        }

        public static IQueryable<Blog> WithBlogShortName(this IQueryable<Blog> query, string name)
        {
            return from b in query where b.ShortName == name select b;
        }

        public static IQueryable<PostCategory> WithBlogId(this IQueryable<PostCategory> query, int Id)
        {
            return from pc in query where pc.BlogId == Id select pc;
        }

        public static IQueryable<PostCategory> WithPostCategoryId(this IQueryable<PostCategory> query, int Id)
        {
            return from pc in query where pc.ID == Id select pc;
        }

        public static IQueryable<Post> WithPostId(this IQueryable<Post> query, int Id)
        {
            return from p in query where p.ID == Id select p;
        }

        public static IQueryable<Post> PostsForSingleBlog(this IQueryable<Post> query, Blog b)
        {

            return from p in query
                   where p.BlogId == b.ID
                   select p;
        }

        public static IQueryable<PostComment> PostCommentsForSinglePost(this IQueryable<PostComment> query, Post p)
        {

            return from pc in query
                   where pc.PostID == p.ID
                   select pc;
        }


    }
}
